<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>imageload</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="imagegetpixel.html" title="imagegetpixel" />
    <link rel="next" href="imagesave.html" title="imagesave" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">imageload</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="imagegetpixel.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="imagesave.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="imageload"></a>
      <div class="titlepage"></div>
      <a id="IndexImageload" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">imageload</span>
        </h2>
        <p>imageload — 
      Load an image.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp115665792"></a>
        <h2>Description</h2>
        <p>
      Load an image and return a reference to it. Individual pixel values can then be accessed with <a class="link" href="imagegetpixel.html" title="imagegetpixel"><em class="citetitle">imagegetpixel</em></a>.
    </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>The image processing opcodes can only load png images</p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1">
        <a id="idp115668528"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">iimagenum <span class="command"><strong>imageload</strong></span> filename</pre>
      </div>
      <div class="refsect1">
        <a id="idp115670768"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>iimagenum</em></span> -- number assigned to the loaded image.
    </p>
        <p>
      <span class="emphasis"><em>filename</em></span> -- The filename of the image to load (should be a valid PNG image file).
    </p>
      </div>
      <div class="refsect1">
        <a id="idp115673488"></a>
        <h2>Examples</h2>
        <p>
	    Here is an example of the imageload opcode. It uses the file <a class="ulink" href="examples/imageopcodes.csd" target="_top"><em class="citetitle">imageopcodes.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp115675280"></a>
          <p class="title">
            <strong>Example 388. Example of the imageload opcode.</strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-n <span class="comment">;no sound output</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span><span class="op">=</span>48000
<span class="ohdr">ksmps</span><span class="op">=</span>1
<span class="ohdr">nchnls</span><span class="op">=</span>2

<span class="comment">; this test .csd copies image.png into a new file 'imageout.png'</span>

giimage1 <span class="opc">imageload</span> "image.png"
giimagew, giimageh <span class="opc">imagesize</span> giimage1
giimage2 <span class="opc">imagecreate</span> giimagew,giimageh

    <span class="oblock">instr</span> 1

kndx <span class="op">=</span> 0
kx_ <span class="opc">linseg</span> 0, p3, 1
<span class="comment">;print imagewidth and imageheigth of image.png</span>
<span class="opc">prints</span> "imagewidth <span class="op">=</span> <span class="op">%</span>f pixels, imageheigth <span class="op">=</span> <span class="op">%</span>f pixels\\n", giimagew, giimageh

<span class="olabel">myloop</span><span class="op">:</span>
ky_ <span class="op">=</span> kndx<span class="op">/</span>(giimageh)
kr_, kg_, kb_ <span class="opc">imagegetpixel</span> giimage1, kx_, ky_
<span class="opc">imagesetpixel</span> giimage2, kx_, ky_, kr_, kg_, kb_
<span class="octrl">loop_lt</span> kndx, 0.5, giimageh, <span class="olabel">myloop</span>
    <span class="oblock">endin</span>

    <span class="oblock">instr</span> 2

<span class="opc">imagesave</span> giimage2, "imageout.png"
    <span class="oblock">endin</span>

    <span class="oblock">instr</span> 3
<span class="opc">imagefree</span> giimage1
<span class="opc">imagefree</span> giimage2
    <span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">i</span>1 1 1
<span class="stamnt">i</span>2 2 1
<span class="stamnt">i</span>3 3 1
<span class="stamnt">e</span>

<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp115677200"></a>
        <h2>See Also</h2>
        <p>
	    <a class="link" href="imagecreate.html" title="imagecreate"><em class="citetitle">imagecreate</em></a>,
	    <a class="link" href="imagesize.html" title="imagesize"><em class="citetitle">imagesize</em></a>,
	    <a class="link" href="imagesave.html" title="imagesave"><em class="citetitle">imagesave</em></a>,
	    <a class="link" href="imagegetpixel.html" title="imagegetpixel"><em class="citetitle">imagegetpixel</em></a>,
	    <a class="link" href="imagesetpixel.html" title="imagesetpixel"><em class="citetitle">imagesetpixel</em></a>,
   	<a class="link" href="imagefree.html" title="imagefree"><em class="citetitle">imagefree</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp115684112"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Cesare Marilungo</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 5.08</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="imagegetpixel.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="imagesave.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">imagegetpixel </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> imagesave</td>
        </tr>
      </table>
    </div>
  </body>
</html>
